package com.chixing.controller;


import com.chixing.entity.Dish;
import com.chixing.service.IDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yebken.
 * @since 2025-06-25
 */
@RestController
@RequestMapping("/dish")
public class DishController {
    @Autowired
    private IDishService dishService;

    @GetMapping()
    public List<Dish> getAll(){
        return dishService.getAll();
    }

    //根据id查询菜品
    @GetMapping("{dishId}")
    public Dish getById(@PathVariable("dishId") Integer dishId){
        return dishService.getById(dishId);
    }

    //根据类型查询菜品
    @GetMapping("type/{typeId}")
    public List<Dish> getByType(@PathVariable("typeId") Integer typeId){
        return dishService.getByType(typeId);
    }

    //根据名称查询菜品
    @GetMapping("name/{dishName}")
    public List<Dish> getByName(@PathVariable("dishName") String dishName){
        return dishService.getByName(dishName);
    }

}
